<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('LPN管理')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline" style="width: 190px">
                        <label class="layui-form-label">货品名称</label>
                        <div class="layui-inline">
                            <input type="text" name="mc" placeholder="请输入货品名称"  class="layui-input" style="width: 190px">
                        </div>
                    </div>
                    <div class="layui-inline" style="width: 190px">
                        <label class="layui-form-label">货品编号</label>
                        <div class="layui-inline">
                            <input type="text" name="bh" placeholder="请输入货品编号"  class="layui-input" style="width: 190px">
                        </div>
                    </div>
                    <div class="layui-inline" style="width: 190px">
                        <label class="layui-form-label">种类名称</label>
                        <div class="layui-inline">
                            <input type="text" name="zlmc" placeholder="请输入种类名称"  class="layui-input" style="width: 190px">
                        </div>
                    </div>
                    <div class="layui-inline" style="width: 190px">
                        <label class="layui-form-label">NC编码</label>
                        <div class="layui-inline">
                            <input type="text" name="nc" placeholder="请输入NC编码"  class="layui-input" style="width: 190px">
                        </div>
                    </div>
                    <!--<div class="layui-inline" style="width: 190px">-->
                        <!--<label class="layui-form-label">外部编号1</label>-->
                        <!--<div class="layui-inline">-->
                            <!--<input type="text" name="erp_code1" placeholder="请输入外部编号1"  class="layui-input" style="width: 190px">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="layui-inline" style="width: 190px">-->
                        <!--<label class="layui-form-label">外部编号2</label>-->
                        <!--<div class="layui-inline">-->
                            <!--<input type="text" name="erp_code2" placeholder="请输入外部编号2"  class="layui-input" style="width: 190px">-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload" id="search_button"> 搜索 </a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #40AFFE">重置</button>
                    </div>
                    <!--<div class="moreSearch" style="display: none">-->
                        <!--<div class="layui-inline">-->
                            <!--<label class="layui-form-label">货品种类</label>-->
                            <!--<div class="layui-input-inline">-->
                                <!--<select lay-ignore="lay-ignore" class="js-data-example-ajax" name="zlmc" style="width: 193px"></select>-->
                            <!--</div>-->
                        <!--</div>-->
                        <!--<div class="layui-inline">-->
                            <!--<label class="layui-form-label">采集序列号</label>-->
                            <!--<select name="cjsn" lay-filter="aihao">-->
                                <!--<option value="">全部</option>-->
                                <!--<option value="0">不采集SN码</option>-->
                                <!--<option value="1">采集SN码</option>-->
                            <!--</select>-->
                        <!--</div>-->
                        <!--<div class="layui-inline">-->
                            <!--<label class="layui-form-label">货品类型</label>-->
                            <!--<select name="goods_type" lay-filter="aihao">-->
                                <!--<option value="">全部</option>-->
                                <!--<option value="0">销售货品</option>-->
                                <!--<option value="1">辅销品</option>-->
                                <!--<option value="2">耗材品</option>-->
                                <!--<option value="3">虚拟产品</option>-->
                            <!--</select>-->
                        <!--</div>-->
                        <!--<div class="layui-inline">-->
                            <!--<label class="layui-form-label">组合产品</label>-->
                            <!--<select name="zhhp" lay-filter="aihao">-->
                                <!--<option value="">全部</option>-->
                                <!--<option value="0">否</option>-->
                                <!--<option value="1">是</option>-->
                            <!--</select>-->
                        <!--</div>-->
                        <!--<div class="layui-inline" style="width: 190px">-->
                            <!--<label class="layui-form-label">供应商</label>-->
                            <!--<div class="layui-inline">-->
                                <!--<input type="text" name="gysmc" placeholder="请输入供应商"  class="layui-input" style="width: 190px">-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
               <!-- <div class="group-button" id="toolbar">
                    <a class="layui-btn layui-btn-sm layui-btn-normal">
                        <i class="layui-icon">&#x1005;</i> 导入
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 新增
                    </a>
                    &lt;!&ndash; Single button &ndash;&gt;
                    &lt;!&ndash;<div class="btn-group">&ndash;&gt;
                        &lt;!&ndash;<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">&ndash;&gt;
                            &lt;!&ndash;多选操作 <span class="caret"></span>&ndash;&gt;
                        &lt;!&ndash;</button>&ndash;&gt;
                        &lt;!&ndash;<ul class="dropdown-menu">&ndash;&gt;
                            &lt;!&ndash;<li><a href="#">多选删除</a></li>&ndash;&gt;
                            &lt;!&ndash;<li><a href="#">多选打印</a></li>&ndash;&gt;
                            &lt;!&ndash;<li><a href="#">明细表</a></li>&ndash;&gt;
                            &lt;!&ndash;<li role="separator" class="divider"></li>&ndash;&gt;
                            &lt;!&ndash;<li><a href="#">Separated link</a></li>&ndash;&gt;
                        &lt;!&ndash;</ul>&ndash;&gt;
                    &lt;!&ndash;</div>&ndash;&gt;
                </div>-->
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body" >
                    <div class="pro">
                        <table id="table"  class="table text-nowrap" style="word-break:break-all; word-wrap:break-word;"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>

<script type="text/javascript" th:src="@{/plugin/layui/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/version.js}"></script>
<script th:src="@{/plugin/layui/js/common.js}"></script>
<div th:include="public/public_js::public_js"></div>
<div th:include="/public/public_btn::public_btn"></div>
<script th:inline="javascript">
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };
    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    })
    var functions = [[${functions}]];
    layui.use(['list','layer','zzpUtils','jquery','laydate','tablebutton'],function () {
        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
            tablebtn = layui.tablebutton;
            tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function () {
                    console.log("点查询了");
                    zzpUtils.refreshTable("#table");
                },
                /*新增*/
                addEvent: function (data) {
                    add();
                },
                /*编辑*/
                editEvent: function (data) {
                    if (data.row != undefined) {
                        editDialog(data);
                    }
                }
            }
        })
        //select2 查货品种类
        $('.js-data-example-ajax').select2({
            ajax: {
                url: '/zxbzwms/wmsgoodstype/getWmsGoodsTypeByHzId',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].mc,text:data[i].mc});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询货品种类',
            allowClear: true
        });
        window.operateEvent ={

            "click .editRow":function (e, value, row, index) {
                alert("dd");
                alert(row.mc);ed
            }
        }
        //查询list
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            isOperate: true,
            pagination:true,
            url: '/wmsgoods/list',
            columns: [{
                field: '',
                checkbox: true
            },{
                field: 'bh',
                title: '货品编号',
                align : 'center'
            },{
                field: 'mc',
                title: '货品名称',
                align : 'center'
            }, {
                field: 'bzmc',
                title: '包装名称',
                align : 'center'
            },{
                field: 'zlmc',
                title: '种类名称',
                align : 'center'
            },{
                field: 'yxq',
                title: '有效期',
                align : 'center'
            },{
                field: 'show_zhhp',
                title: '组合货品',
                align : 'center'
            },{
                field: 'show_bkxs',
                title: '是否不可销售',
                align : 'center'
            },{
                field: 'show_cjsn',
                title: '采集SN码',
                align : 'center'
            },{
                field: 'bhsx',
                title: '补货上限',
                align : 'center'
            },{
                field: 'nc',
                title: 'NC编码',
                align : 'center'
            },{
                field: 'show_sfyx',
                title: '是否有效',
                align : 'center'
            },{
                field: 'show_yxqkz',
                title: '有效期控制',
                align : 'center'
            },{
                field: 'show_zqlx',
                title: '周期类型',
                align : 'center'
            },{
                field: 'hzmc',
                title: '货主名称',
                align : 'center'
            },{
                field: 'sxqyj',
                title: '失效期预警',
                align : 'center'
            },{
                field: 'sxqyj',
                title: '是否存在物料清单',
                align : 'center'
            }/*,{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter
            }*/],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            /*定义表格右侧按钮*/
            operateFormatter: operateFormatter
        });

        $("#delBtn").on('click',function () {
            var $rows = $table.bootstrapTable('getSelections');
            if($rows.length == 0){
                layer.msg("请选择一条进行删除");
            }else{
                var ids = $.map($rows,function (row) {
                    return row.id;
                })
                alert(ids.join(','));
            }
        })
      /*  function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-primary layui-btn-xs" >查看</a>',
                '<a class="layui-btn layui-btn-xs editRow">编辑</a>',
                '<a class="layui-btn layui-btn-danger layui-btn-xs">删除</a>'
            ].join('')
        }*/

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            var button = '<a class="tooltip2" id="tooltip' + row.id + '" data-tooltip-content="#tool' + row.id + '" id="btn_start"><i class="layui-icon layui-icon-more"></i></a>'
                + '<div class="tooltip_templates">'
                + '<span id="tool' + row.id + '">';
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var btn = '<a class="layui-btn layui-btn-sm layui-btn-warm" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';
                /* button += btn;*/

                if (functions.tableBtn[i].name == '预检') {
                    button += btn;
                }

                if (row.rwzt==0) {
                    if (functions.tableBtn[i].name == '关闭盘点') {
                        button += btn;
                    }
                }

                button += btn;
               /* if( row.rwzt==0 && row.zt==0){

                    if (functions.tableBtn[i].name == '生成盘点任务') {
                        button += btn;
                    }
                }
                if(row.zt==0 && row.rwzt==1){
                    if (functions.tableBtn[i].name == '取消盘点任务') {
                        button += btn;
                    }
                }
                if(row.rwzt==1){
                    if (functions.tableBtn[i].name == '库存盘点') {
                        button += btn;
                    }
                }
                if(row.cyzt==2){
                    if (functions.tableBtn[i].name == '生成库存调整单') {
                        button += btn;
                    }
                }
                if(row.rwzt==1){
                    if (functions.tableBtn[i].name == '盘点任务下发') {
                        button += btn;
                    }
                }*/
            }
            button += '</span>'
                + '</div>';
            return button;

        }
        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        })
        //跳转生成添加页面
        function add(){
            zzpUtils.dialog({
                title:"新增货品",
                type:2,
                content: "/goods/toGoodAdd",
                area: ['1350px', '630px'],
                maxmin: true,
                btn:[],
                end: function () {//添加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }

        //编辑货品
        function editDialog(data) {
            var id=data.row.id;
                zzpUtils.dialog({
                    title: "修改货品",
                    type: 2,
                    content: "/goods/toGoodEdit?id=" + id,
                    area: ['1350px', '630px'], //设置dialog大小，也可以不设置，
                    end: function () {//修改成功后刷新
                        zzpUtils.refreshTable("#table");
                    }
                });

        }
    });
</script>
</html>